<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Ht/index')}">列表</a></li>
        <li class="active"><a>编辑</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('Ht/editPost')}">
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 合同编号:</label>
            <div class="col-md-6 col-sm-10">
                <input placeholder="" type="text" class="form-control" name="ht_number"
                       value="{$vo.ht_number|default=''}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 合同名称:</label>
            <div class="col-md-6 col-sm-10">
                <input placeholder="" type="text" class="form-control" name="ht_name" value="{$vo.ht_name|default=''}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 归属类型:</label>
            <div class="col-md-6 col-sm-10">
                <select name="companytype" class="form-control">
                    <volist name="companytypea_arr" id="ao">
                        <option
                        <if isset($vo.companytype)&&$vo.companytype==$ao.id>selected</if>
                        value="{$ao.id}">{$ao.name}</option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 客户名称:</label>
            <div class="col-md-6 col-sm-10">
                <select name="company_id" class="form-control">
                    <option value="">请选择</option>
                    <volist name="company_id_arr" id="ao">
                        <option
                        <if isset($vo.company_id)&&$vo.company_id==$ao.id>selected</if>
                        value="{$ao.id}">{$ao.name}</option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 牌号:</label>
            <div class="col-md-6 col-sm-10">
                <select name="ht_grade_id" class="form-control">
                    <option value="">请选择</option>
                    <volist name="ht_grade_arr" id="ao">
                        <option
                        <if isset($vo.ht_grade_id)&&$vo.ht_steel_grade_id==$ao.id>selected</if>
                        value="{$ao.id}">{$ao.g_name}</option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 厚（mm）:</label>
            <div class="col-md-6 col-sm-10">
                <input placeholder="" type="number" class="form-control" id="ht_d" name="ht_d" value="{$vo.ht_d|default=''}" onchange="issheets()">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 宽（mm）:</label>
            <div class="col-md-6 col-sm-10">
                <input placeholder="" type="number" class="form-control" id="ht_w" name="ht_w" value="{$vo.ht_w|default=''}" onchange="issheets()">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 长（mm）:</label>
            <div class="col-md-6 col-sm-10">
                <input placeholder="" type="text" class="form-control" id="ht_h" name="ht_h" value="{$vo.ht_h|default=''}" onchange="issheets()">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 重量(吨):</label>
            <div class="col-md-6 col-sm-10">
                <input placeholder="" type="number" class="form-control" id="ht_tw" name="ht_tw" value="{$vo.ht_tw|default=''}" onchange="issheets()">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 交货时间:</label>
            <div class="col-md-6 col-sm-10">
                <input autocomplete="off" type="text" class="form-control js-datetime" name="delivery_time"
                       value="{:date('Y-m-d H:i',$vo['delivery_time'])}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 图片附件:</label>
            <div class="col-md-6 col-sm-10">
                <input readonly style="display: inline-block;width:80%;" class="form-control" name="image_enclosure"
                       id="image_enclosure"
                       type="text"
                       title="图片名称" value="{$vo.image_enclosure}">
                <a class="btn btn-success"
                   href="javascript:uploadMultiFile('图片上传','#image_enclosureCnt','#image_enclosure','image');">上传</a>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span> 预览</label>
            <div id="image_enclosureCnt" class="col-md-6 col-sm-10">
                <volist name=":explode(',',$vo.image_enclosure)" id="ao">
                    <if condition="$ao">
                    <div style="display: inline-block;width:70px;position: relative;">
                        <img data-src="{$domain}{$ao}" onclick="bigSee(this)"
                             style="width:70px;height:70px;margin-right:5px;" src="{$domain}{$ao}">
                        <div data-src="{$ao}" onclick="delImg(this,'#image_enclosure')" title="删除"
                             style="cursor:pointer;width:15px;height:15px;border-radius: 50%;background: red;color:white;text-align: center;line-height: 15px;position: absolute;right:0;top:0;z-index: 20;">
                            -
                        </div>
                    </div>
                    </if>
                </volist>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 文件附件:</label>
            <div class="col-md-6 col-sm-10">
                <input readonly style="display: inline-block;width:80%;" class="form-control" name="file_enclosure"
                       id="file_enclosure"
                       type="text"
                       title="图片名称" value="{$vo.file_enclosure}">
                <a class="btn btn-success"
                   href="javascript:uploadMultiFile('文件上传','#file_enclosureCnt','#file_enclosure','file');">上传</a>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span> 预览</label>
            <div id="file_enclosureCnt" class="col-md-6 col-sm-10">
                <volist name=":explode(',',$vo.file_enclosure)" id="ao">
                    <if condition="$ao">
                    <div style="display: inline-block;width:70px;position: relative;">
                        <img data-src="{$domain}{$ao}" onclick="bigSee(this)"
                             style="width:70px;height:70px;margin-right:5px;"
                             src="/static/images/autocode_filelogo.png">
                        <div data-src="{$ao}" onclick="delImg(this,'#file_enclosure')" title="删除"
                             style="cursor:pointer;width:15px;height:15px;border-radius: 50%;background: red;color:white;text-align: center;line-height: 15px;position: absolute;right:0;top:0;z-index: 20;">
                            -
                        </div>
                    </div>
                    </if>
                </volist>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required"></span> 备注:</label>
            <div class="col-md-6 col-sm-10">
                <input placeholder="" type="text" class="form-control" name="remark"
                       value="{$vo.remark|default=''}">
            </div>
        </div>
        <div class="col-sm-offset-2 col-sm-10">
            <input type="hidden" name="id" value="{$vo.id}"/>
            <button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
            <a class="btn btn-default" href="{:url('Ht/index')}">返回</a>
        </div>
    </form>

</div>
<script src="/static/js/admin.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script>
    //预览图片
    function bigSee(obj) {
        let src = $(obj).data('src');
        layer.open({
            title: '图片预览',
            area: ['50%', '100%'],
            content: `<iframe style="width:100%;height:100%;border:0;outline:0;" src="${src}"></iframe>`,
        });
    }

    /**
     * 删除图片
     * @param obj
     */
    function delImg(obj, idFlag = '#photo') {

        let oldPath = $(idFlag).val().trim();
        if (!oldPath) {
            return '';
        }

        let deleteRes = [$(obj).data('src')];
        oldPath = oldPath.split(',');
        oldPath = oldPath.filter(v => !deleteRes.some((item) => item === v))

        oldPath = oldPath.join(',');

        $(idFlag).val(oldPath);
        //删除原图片
        $(obj).parent().remove();
    }//预览
    function bigSee(obj) {
        let src = $(obj).data('src');
        layer.open({
            title: '文件预览',
            area: ['50%', '100%'],
            content: `<iframe style="width:100%;height:100%;border:0;outline:0;" src="${src}"></iframe>`,
        });
    }

    /**
     * 删除
     * @param obj
     */
    function delImg(obj, idFlag = '#photo') {

        let oldPath = $(idFlag).val().trim();
        if (!oldPath) {
            return '';
        }

        let deleteRes = [$(obj).data('src')];
        oldPath = oldPath.split(',');
        oldPath = oldPath.filter(v => !deleteRes.some((item) => item === v))

        oldPath = oldPath.join(',');

        $(idFlag).val(oldPath);
        //删除原图片
        $(obj).parent().remove();
    }
</script>
</body>
</html>